{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>.container { width:60% !important; }</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import os\n",
    "import scipy\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from collections import defaultdict\n",
    "from matplotlib.colors import ListedColormap\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib as mpl\n",
    "import matplotlib\n",
    "\n",
    "import pandas as pd\n",
    "pd.set_option('display.max_rows', 5000)\n",
    "pd.set_option('display.max_columns', 5000)\n",
    "pd.set_option('display.width', 10000)\n",
    "\n",
    "from collections import defaultdict\n",
    "from IPython.display import display, HTML\n",
    "\n",
    "import seaborn as sns\n",
    "sns.set_style('whitegrid')\n",
    "\n",
    "%matplotlib inline \n",
    "current_palette = sns.color_palette()\n",
    "cmap = current_palette.as_hex()\n",
    "\n",
    "from IPython.core.display import display, HTML\n",
    "display(HTML(\"<style>.container { width:60% !important; }</style>\"))\n",
    "\n",
    "current_palette = sns.color_palette()\n",
    "cmap = ListedColormap(current_palette.as_hex())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "colors = {\n",
    "    'deepens': '#1f77b4', \n",
    "    'dropout': '#ff7f0e',\n",
    "    'kfacl': '#2ca02c',\n",
    "    'onenet': '#d62728',\n",
    "    'vi': '#9467bd',\n",
    "    'csgld':'#8c564b',\n",
    "    'sse':'#e377c2',\n",
    "    'swag': '#7f7f7f', \n",
    "    'fge': '#bcbd22'}\n",
    "\n",
    "names = {\n",
    "    'acc': 'Accuracy (%)',\n",
    "    'll': 'Log-Likelihood',\n",
    "    'brier': 'Brier',\n",
    "    'acc-aac': 'AURC'\n",
    "}\n",
    "\n",
    "names_ = {\n",
    "    'deepens': 'Deep ensemble', \n",
    "    'dropout': 'Dropout',\n",
    "    'kfacl': 'K-FAC-L',\n",
    "    'onenet': 'Single model',\n",
    "    'vi': 'FFG VI',\n",
    "    'csgld':'cSGLD',\n",
    "    'sse':'SSE',\n",
    "    'swag': 'SWAG', \n",
    "    'fge': 'FGE'}\n",
    "\n",
    "names_long = {\n",
    "    'deepens': 'Deep Ensembles', \n",
    "    'dropout': 'Dropout',\n",
    "    'kfacl': 'KFAC-Laplace',\n",
    "    'onenet': 'Single model',\n",
    "    'vi': 'Variational Inf. (FFG)',\n",
    "    'csgld':'Cyclic SGLD',\n",
    "    'sse':'Snapshot Ensembles',\n",
    "    'swag': 'SWA-Gaussian', \n",
    "    'fge': 'Fast Geometric Ens.', \n",
    "    'stochbn':'SBN'}\n",
    "\n",
    "    \n",
    "precition = {\n",
    "    'acc': '%.2f',\n",
    "    'acc@5': '%.2f',\n",
    "    'll':  '%.3f',\n",
    "    'brier': '%.3f',\n",
    "    'acc-aac': '%.4f',\n",
    "    'dee': '%.1f'\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Reading log-files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!unzip logs.zip > unzip_out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = './logs/'\n",
    "df = pd.concat([pd.read_csv(path + f) for f in os.listdir(path)], sort=False)\n",
    "df.model = df.model.apply(lambda x: x.replace('do', '').replace('Bayes', ''))\n",
    "df.metric = df.metric.apply(lambda x: x.replace('_', '-'))\n",
    "df.method = df.method.apply(lambda x: x.lower().replace('_', '-').replace('kfaclaplace', 'kfacl'))\n",
    "df = df[df.metric.apply(lambda x: x in ['acc-aac', 'acc', 'll', 'brier'])]\n",
    "\n",
    "df.model = df.model.apply(\n",
    "    lambda x: x.replace('BN', '').replace('Pre', '').replace('28x10', ''))\n",
    "dfbase_ung = df\n",
    "dfbase = df.groupby(\n",
    "    ['dataset', 'model', 'method', 'n_samples', 'metric']\n",
    ").value.agg(['mean', 'std', len]).reset_index()\n",
    "dfbase = dfbase[dfbase.method.apply(lambda x: 'stochbn' not in x)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>dataset</th>\n",
       "      <th>model</th>\n",
       "      <th>method</th>\n",
       "      <th>n_samples</th>\n",
       "      <th>metric</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>len</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>33966</th>\n",
       "      <td>CIFAR10</td>\n",
       "      <td>VGG16</td>\n",
       "      <td>onenet</td>\n",
       "      <td>92</td>\n",
       "      <td>brier</td>\n",
       "      <td>0.102627</td>\n",
       "      <td>0.001480</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53971</th>\n",
       "      <td>CIFAR10</td>\n",
       "      <td>WideResNet</td>\n",
       "      <td>vi-augment</td>\n",
       "      <td>93</td>\n",
       "      <td>ll</td>\n",
       "      <td>-0.125742</td>\n",
       "      <td>0.000195</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69206</th>\n",
       "      <td>CIFAR100</td>\n",
       "      <td>ResNet164</td>\n",
       "      <td>deepens (ts)</td>\n",
       "      <td>2</td>\n",
       "      <td>brier</td>\n",
       "      <td>0.275663</td>\n",
       "      <td>0.002134</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        dataset       model        method  n_samples metric      mean       std  len\n",
       "33966   CIFAR10       VGG16        onenet         92  brier  0.102627  0.001480  5.0\n",
       "53971   CIFAR10  WideResNet    vi-augment         93     ll -0.125742  0.000195  5.0\n",
       "69206  CIFAR100   ResNet164  deepens (ts)          2  brier  0.275663  0.002134  5.0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfbase.sample(frac=0.0001).head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How to read the table \n",
    "\n",
    "1. Methods (dfbase.method)\n",
    "    - Available methods: ```kfacl, vi, csgld, sse, dropout, fge, swag, deepens, onenet```\n",
    "    - All methods can be combined with ```'(ts)'``` substring that denotes a method with a temperature-scaling.\n",
    "    - All methods can be combined with ```'-augment'``` substring that denotes test-time augmentation---one augmentation of an image per one member of an ensemble.\n",
    "2. Datasets (dfbase.dataset column): \n",
    "    - Available datasets: `CIFAR100, CIFAR10, ImageNet`\n",
    "3. Models (dfbase.model):\n",
    "    - Available models for CIFAR-10/100: ```VGG16, ResNet110, WideResNet, ResNet164```\n",
    "    - Available model for ImageNet is ```ResNet50```\n",
    "4. Size of an ensemble \n",
    "    - Number of members of an ensemble (`dfbase.n_samples`) typically is 1-100 for CIFARs and 1-50 for ImageNet.\n",
    "5. Metrics:\n",
    "    - Available metrics: `acc, ll, brier, acc-aac`\n",
    "    - Where df.mean and df.std stores mean and standard deviation.\n",
    "    \n",
    "### How to work with data frame \n",
    "1. We find `df.query` quite usefull. There is an example: `dfbase.query(\"method=='deepens' and dataset=='ImageNet' and metric=='acc' and n_samples<5\")`  \n",
    "2. Iteration via a data frame is also very usefull. There is an example: `for row in dfbase.values[:3]: print (row)`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Accuracy (%)</th>\n",
       "      <th>cSGLD*</th>\n",
       "      <th>Deep ensemble*</th>\n",
       "      <th>FGE*</th>\n",
       "      <th>K-FAC-L*</th>\n",
       "      <th>Single model*</th>\n",
       "      <th>SSE*</th>\n",
       "      <th>SWAG*</th>\n",
       "      <th>FFG VI*</th>\n",
       "      <th>Dropout*</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>ResNet110</th>\n",
       "      <td>18.07±0.16</td>\n",
       "      <td>16.97±0.07</td>\n",
       "      <td>19.64±0.15</td>\n",
       "      <td>22.14±0.29</td>\n",
       "      <td>22.66±0.31</td>\n",
       "      <td>18.48±0.25</td>\n",
       "      <td>20.69±0.19</td>\n",
       "      <td>21.86±0.07</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ResNet164</th>\n",
       "      <td>17.13±0.18</td>\n",
       "      <td>16.50±0.01</td>\n",
       "      <td>18.73±0.25</td>\n",
       "      <td>21.03±0.38</td>\n",
       "      <td>21.39±0.40</td>\n",
       "      <td>17.68±0.07</td>\n",
       "      <td>19.48±0.19</td>\n",
       "      <td>20.82±0.04</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>VGG16</th>\n",
       "      <td>21.15±0.11</td>\n",
       "      <td>19.88±0.10</td>\n",
       "      <td>22.78±0.22</td>\n",
       "      <td>25.70±0.38</td>\n",
       "      <td>25.44±0.29</td>\n",
       "      <td>21.03±0.10</td>\n",
       "      <td>22.97±0.20</td>\n",
       "      <td>24.56±0.07</td>\n",
       "      <td>25.60±0.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WideResNet</th>\n",
       "      <td>16.29±0.10</td>\n",
       "      <td>15.77±0.04</td>\n",
       "      <td>17.12±0.16</td>\n",
       "      <td>19.43±0.21</td>\n",
       "      <td>19.31±0.24</td>\n",
       "      <td>16.07±0.07</td>\n",
       "      <td>17.08±0.19</td>\n",
       "      <td>18.74±0.08</td>\n",
       "      <td>19.22±0.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Accuracy (%)      cSGLD* Deep ensemble*        FGE*    K-FAC-L* Single model*        SSE*       SWAG*     FFG VI*    Dropout*\n",
       "ResNet110     18.07±0.16     16.97±0.07  19.64±0.15  22.14±0.29    22.66±0.31  18.48±0.25  20.69±0.19  21.86±0.07            \n",
       "ResNet164     17.13±0.18     16.50±0.01  18.73±0.25  21.03±0.38    21.39±0.40  17.68±0.07  19.48±0.19  20.82±0.04            \n",
       "VGG16         21.15±0.11     19.88±0.10  22.78±0.22  25.70±0.38    25.44±0.29  21.03±0.10  22.97±0.20  24.56±0.07  25.60±0.17\n",
       "WideResNet    16.29±0.10     15.77±0.04  17.12±0.16  19.43±0.21    19.31±0.24  16.07±0.07  17.08±0.19  18.74±0.08  19.22±0.15"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = dfbase\n",
    "ts = True\n",
    "addlen = False\n",
    "if ts: df = dfbase[dfbase.method.apply(lambda x: 'ts' in x)]\n",
    "else:  df = dfbase[dfbase.method.apply(lambda x: 'ts' not in x)]\n",
    "latex = True\n",
    "td = defaultdict(lambda: dict())\n",
    "    \n",
    "for dataset_, ns_ in [('CIFAR100', 100)]:\n",
    "    for metric_ in ['acc']:\n",
    "        label = '%s_%s_%s' % (dataset_, metric_, ns_) \n",
    "        for i in df.values:\n",
    "            dataset, model, metod, ns, metric, val, std, len_ = i \n",
    "            if '-augment' in metod: continue\n",
    "            metod = metod.replace('-augment', '')\n",
    "            if dataset == dataset_  and metric == metric_ and ns == ns_:\n",
    "                opt_t = ' (ts)' in metod\n",
    "                metod = names_[metod.replace(' (ts)', '')]\n",
    "                # model += ' (%s samples)' % ns_\n",
    "                if opt_t: metod = metod+'*'\n",
    "                if metric == 'acc':\n",
    "                    td[metod][model] = '%.2f%s' % (100*(1-val), (('±%.2f' % (std*100)) if str(std) != 'nan' else ''))\n",
    "                elif metric == 'acc-aac':\n",
    "                    td[metod][model] = '%.4f±%.2f' % (val, std)\n",
    "                elif metric=='ll':\n",
    "                    td[metod][model] = '%.3f%s' % (-val, (('±%.3f' % std) if str(std) != 'nan' else ''))\n",
    "                td[metod][model].replace('nan', '')\n",
    "        \n",
    "        df_ = pd.DataFrame.from_dict(td) \n",
    "        df_ = df_.replace(np.nan, '', regex=True)\n",
    "        cap = '%s on %s dataset for diferent number of samples' % (('c' if ts and metric_ != 'acc' else '') + names[metric_], dataset_)\n",
    "\n",
    "        df_.columns.name = '%s' % (('Neg. ' if metric_ == 'll' else '') + names[metric_])\n",
    "        display(df_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Accuracy (%)</th>\n",
       "      <th>ResNet110</th>\n",
       "      <th>ResNet164</th>\n",
       "      <th>VGG16</th>\n",
       "      <th>WideResNet</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>cSGLD*</th>\n",
       "      <td>18.07±0.16</td>\n",
       "      <td>17.13±0.18</td>\n",
       "      <td>21.15±0.11</td>\n",
       "      <td>16.29±0.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Deep ensemble*</th>\n",
       "      <td>16.97±0.07</td>\n",
       "      <td>16.50±0.01</td>\n",
       "      <td>19.88±0.10</td>\n",
       "      <td>15.77±0.04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>FGE*</th>\n",
       "      <td>19.64±0.15</td>\n",
       "      <td>18.73±0.25</td>\n",
       "      <td>22.78±0.22</td>\n",
       "      <td>17.12±0.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>K-FAC-L*</th>\n",
       "      <td>22.14±0.29</td>\n",
       "      <td>21.03±0.38</td>\n",
       "      <td>25.70±0.38</td>\n",
       "      <td>19.43±0.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Single model*</th>\n",
       "      <td>22.66±0.31</td>\n",
       "      <td>21.39±0.40</td>\n",
       "      <td>25.44±0.29</td>\n",
       "      <td>19.31±0.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SSE*</th>\n",
       "      <td>18.48±0.25</td>\n",
       "      <td>17.68±0.07</td>\n",
       "      <td>21.03±0.10</td>\n",
       "      <td>16.07±0.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SWAG*</th>\n",
       "      <td>20.69±0.19</td>\n",
       "      <td>19.48±0.19</td>\n",
       "      <td>22.97±0.20</td>\n",
       "      <td>17.08±0.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>FFG VI*</th>\n",
       "      <td>21.86±0.07</td>\n",
       "      <td>20.82±0.04</td>\n",
       "      <td>24.56±0.07</td>\n",
       "      <td>18.74±0.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Dropout*</th>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>25.60±0.17</td>\n",
       "      <td>19.22±0.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Accuracy (%)     ResNet110   ResNet164       VGG16  WideResNet\n",
       "cSGLD*          18.07±0.16  17.13±0.18  21.15±0.11  16.29±0.10\n",
       "Deep ensemble*  16.97±0.07  16.50±0.01  19.88±0.10  15.77±0.04\n",
       "FGE*            19.64±0.15  18.73±0.25  22.78±0.22  17.12±0.16\n",
       "K-FAC-L*        22.14±0.29  21.03±0.38  25.70±0.38  19.43±0.21\n",
       "Single model*   22.66±0.31  21.39±0.40  25.44±0.29  19.31±0.24\n",
       "SSE*            18.48±0.25  17.68±0.07  21.03±0.10  16.07±0.07\n",
       "SWAG*           20.69±0.19  19.48±0.19  22.97±0.20  17.08±0.19\n",
       "FFG VI*         21.86±0.07  20.82±0.04  24.56±0.07  18.74±0.08\n",
       "Dropout*                                25.60±0.17  19.22±0.15"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = dfbase\n",
    "ts = True\n",
    "addlen = False\n",
    "if ts: df = dfbase[dfbase.method.apply(lambda x: 'ts' in x)]\n",
    "else:  df = dfbase[dfbase.method.apply(lambda x: 'ts' not in x)]\n",
    "latex = True\n",
    "td = defaultdict(lambda: dict())\n",
    "    \n",
    "for dataset_, ns_ in [('CIFAR100', 100)]:\n",
    "    for metric_ in ['acc']:\n",
    "        label = '%s_%s_%s' % (dataset_, metric_, ns_) \n",
    "        for i in df.values:\n",
    "            dataset, model, metod, ns, metric, val, std, len_ = i \n",
    "            if '-augment' in metod: continue\n",
    "            metod = metod.replace('-augment', '')\n",
    "            if dataset == dataset_  and metric == metric_ and ns == ns_:\n",
    "                opt_t = ' (ts)' in metod\n",
    "                metod = names_[metod.replace(' (ts)', '')]\n",
    "                # model += ' (%s samples)' % ns_\n",
    "                if opt_t: metod = metod+'*'\n",
    "                if metric == 'acc':\n",
    "                    td[model][metod] = '%.2f%s' % (100*(1-val), (('±%.2f' % (std*100)) if str(std) != 'nan' else ''))\n",
    "                elif metric == 'acc-aac':\n",
    "                    td[model][metod] = '%.4f±%.2f' % (val, std)\n",
    "                elif metric=='ll':\n",
    "                    td[model][metod] = '%.3f%s' % (-val, (('±%.3f' % std) if str(std) != 'nan' else ''))\n",
    "                td[model][metod].replace('nan', '')\n",
    "        \n",
    "        df_ = pd.DataFrame.from_dict(td) \n",
    "        df_ = df_.replace(np.nan, '', regex=True)\n",
    "        cap = '%s on %s dataset for diferent number of samples' % (('c' if ts and metric_ != 'acc' else '') + names[metric_], dataset_)\n",
    "\n",
    "        df_.columns.name = '%s' % (('Neg. ' if metric_ == 'll' else '') + names[metric_])\n",
    "        display(df_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Ensembling Method</th>\n",
       "      <th>ResNet50 (1)</th>\n",
       "      <th>ResNet50 (10)</th>\n",
       "      <th>ResNet50 (50)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Deep Ensembles</th>\n",
       "      <td>$0.935$ vs $1.292$±0.005↑</td>\n",
       "      <td>$0.805$ vs $0.793$±0.002↓</td>\n",
       "      <td>$0.788$ vs $0.739$±0.000↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Fast Geometric Ens.</th>\n",
       "      <td>$0.929$ vs $1.288$±0.008↑</td>\n",
       "      <td>$0.916$ vs $0.842$±0.001↓</td>\n",
       "      <td>$0.904$ vs $0.793$±0.001↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>KFAC-Laplace</th>\n",
       "      <td>$0.988$ vs $1.298$±0.008↑</td>\n",
       "      <td>$0.939$ vs $0.855$±0.005↓</td>\n",
       "      <td>$0.934$ vs $0.809$±0.004↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Single model</th>\n",
       "      <td>$0.938$ vs $1.292$±0.006↑</td>\n",
       "      <td>$0.938$ vs $0.851$±0.004↓</td>\n",
       "      <td>$0.938$ vs $0.805$±0.003↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Snapshot Ensembles</th>\n",
       "      <td>$0.983$ vs $1.361$±0.005↑</td>\n",
       "      <td>$0.843$ vs $0.815$±0.002↓</td>\n",
       "      <td>$0.830$ vs $0.763$±0.000↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Variational Inf. (FFG)</th>\n",
       "      <td>$0.957$ vs $1.326$±0.007↑</td>\n",
       "      <td>$0.923$ vs $0.851$±0.001↓</td>\n",
       "      <td>$0.920$ vs $0.805$±0.001↓</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Ensembling Method                    ResNet50 (1)              ResNet50 (10)              ResNet50 (50)\n",
       "Deep Ensembles          $0.935$ vs $1.292$±0.005↑  $0.805$ vs $0.793$±0.002↓  $0.788$ vs $0.739$±0.000↓\n",
       "Fast Geometric Ens.     $0.929$ vs $1.288$±0.008↑  $0.916$ vs $0.842$±0.001↓  $0.904$ vs $0.793$±0.001↓\n",
       "KFAC-Laplace            $0.988$ vs $1.298$±0.008↑  $0.939$ vs $0.855$±0.005↓  $0.934$ vs $0.809$±0.004↓\n",
       "Single model            $0.938$ vs $1.292$±0.006↑  $0.938$ vs $0.851$±0.004↓  $0.938$ vs $0.805$±0.003↓\n",
       "Snapshot Ensembles      $0.983$ vs $1.361$±0.005↑  $0.843$ vs $0.815$±0.002↓  $0.830$ vs $0.763$±0.000↓\n",
       "Variational Inf. (FFG)  $0.957$ vs $1.326$±0.007↑  $0.923$ vs $0.851$±0.001↓  $0.920$ vs $0.805$±0.001↓"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\\begin{tabular}{llll}\n",
      "\\toprule\n",
      "Ensembling Method &               ResNet50 (1) &              ResNet50 (10) &              ResNet50 (50) \\\\\n",
      "\\midrule\n",
      "Deep Ensembles         &  $0.935$ vs $1.292${\\tiny $\\pm0.005\\color{darkpink}{\\uparrow}$} &  $0.805$ vs $0.793${\\tiny $\\pm0.002\\color{darkpastelgreen}{\\downarrow}$} &  $0.788$ vs $0.739${\\tiny $\\pm0.000\\color{darkpastelgreen}{\\downarrow}$} \\\\\n",
      "Fast Geometric Ens.    &  $0.929$ vs $1.288${\\tiny $\\pm0.008\\color{darkpink}{\\uparrow}$} &  $0.916$ vs $0.842${\\tiny $\\pm0.001\\color{darkpastelgreen}{\\downarrow}$} &  $0.904$ vs $0.793${\\tiny $\\pm0.001\\color{darkpastelgreen}{\\downarrow}$} \\\\\n",
      "KFAC-Laplace           &  $0.988$ vs $1.298${\\tiny $\\pm0.008\\color{darkpink}{\\uparrow}$} &  $0.939$ vs $0.855${\\tiny $\\pm0.005\\color{darkpastelgreen}{\\downarrow}$} &  $0.934$ vs $0.809${\\tiny $\\pm0.004\\color{darkpastelgreen}{\\downarrow}$} \\\\\n",
      "Single model           &  $0.938$ vs $1.292${\\tiny $\\pm0.006\\color{darkpink}{\\uparrow}$} &  $0.938$ vs $0.851${\\tiny $\\pm0.004\\color{darkpastelgreen}{\\downarrow}$} &  $0.938$ vs $0.805${\\tiny $\\pm0.003\\color{darkpastelgreen}{\\downarrow}$} \\\\\n",
      "Snapshot Ensembles     &  $0.983$ vs $1.361${\\tiny $\\pm0.005\\color{darkpink}{\\uparrow}$} &  $0.843$ vs $0.815${\\tiny $\\pm0.002\\color{darkpastelgreen}{\\downarrow}$} &  $0.830$ vs $0.763${\\tiny $\\pm0.000\\color{darkpastelgreen}{\\downarrow}$} \\\\\n",
      "Variational Inf. (FFG) &  $0.957$ vs $1.326${\\tiny $\\pm0.007\\color{darkpink}{\\uparrow}$} &  $0.923$ vs $0.851${\\tiny $\\pm0.001\\color{darkpastelgreen}{\\downarrow}$} &  $0.920$ vs $0.805${\\tiny $\\pm0.001\\color{darkpastelgreen}{\\downarrow}$} \\\\\n",
      "\\bottomrule\n",
      "\\end{tabular}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "df = dfbase\n",
    "ts = True\n",
    "if ts: df = dfbase[dfbase.method.apply(lambda x: 'ts' in x)]\n",
    "else:  df = dfbase[dfbase.method.apply(lambda x: 'ts' not in x)]\n",
    "\n",
    "td = defaultdict(lambda: dict())\n",
    "for dataset_, ns_ in [('ImageNet', 1), ('ImageNet', 10), ('ImageNet', 50)]:\n",
    "    for metric_ in ['ll']:\n",
    "        label = '%s_%s_%s' % (dataset_, metric_, ns_) \n",
    "        for i in df.values:\n",
    "            dataset, model, metod, ns, metric, val, std, len_ = i \n",
    "            model += ' (%s)' % ns_\n",
    "            if '-augment' not in metod:\n",
    "                opt_t = ' (ts)' in metod\n",
    "                metod = names_long[metod.replace(' (ts)', '')]\n",
    "                if dataset == dataset_  and metric == metric_ and ns == ns_:\n",
    "                    metod, model = model, metod\n",
    "                    if metric=='ll':\n",
    "                        td[metod][model] = (-val)\n",
    "                    \n",
    "        for i in df.values:\n",
    "            dataset, model, metod, ns, metric, val, std, len_ = i \n",
    "            model += ' (%s)' % ns_\n",
    "            if '-augment' in metod:         \n",
    "                metod = metod.replace('-augment', '')\n",
    "                if dataset == dataset_  and metric == metric_ and ns == ns_:\n",
    "                    \n",
    "                    opt_t = ' (ts)' in metod\n",
    "                    if metric == 'll': val=-val\n",
    "                    metod = names_long[metod.replace(' (ts)', '')]\n",
    "                    prev = td[model][metod]\n",
    "                    cur = val if metric!='acc' else (100-100*(val))\n",
    "                    pm = precition[metric]\n",
    "                    \n",
    "                    if (pm % prev) == (pm % cur):\n",
    "                        s = '≈'\n",
    "                    elif prev > cur:\n",
    "                        s = '↓'\n",
    "                    else:\n",
    "                        s = '↑'\n",
    "                        \n",
    "                    vs = '$%s$ vs $%s$' % (precition[metric_], precition[metric_])\n",
    "                    #vs = '%s vs %s' % (precition[metric_], precition[metric_])\n",
    "                    metod, model = model, metod\n",
    "                    if metric == 'll':\n",
    "                        td[metod][model] = vs % (prev, cur)\n",
    "                    td[metod][model] += '±%.3f%s' % (std, s)\n",
    "                        \n",
    "                    \n",
    "        \n",
    "df_ = pd.DataFrame.from_dict(td)\n",
    "df_ = df_.replace(np.nan, '', regex=True)\n",
    "cap = '%s on %s dataset for diferent number of samples' % (('c' if ts and metric_ != 'acc' else '') + names[metric_], dataset_)\n",
    "\n",
    "df_.columns.name = 'Ensembling Method'\n",
    "display(df_)\n",
    "\n",
    "print(df_.to_latex().replace(\n",
    "    '±', '{\\\\tiny $\\pm').replace(\n",
    "    '↑', '\\color{darkpink}{\\\\uparrow}$}').replace(\n",
    "    '↓', '\\color{darkpastelgreen}{\\\\downarrow}$}').replace('\\$', '$'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset = 'ImageNet'\n",
    "models = ['VGG16', 'ResNet110', 'ResNet164', 'WideResNet', 'ResNet50']\n",
    "methods = ['dropout', 'swag', 'csgld', 'fge', 'deepens', 'onenet', 'vi', 'kfacl', 'sse']\n",
    "\n",
    "rows, row_counter = defaultdict(lambda: dict()), 0\n",
    "for model in models:\n",
    "    for method in methods:\n",
    "        metrics = defaultdict(lambda: dict())\n",
    "        metrics_ = defaultdict(lambda: dict())\n",
    "        metrics_std = defaultdict(lambda: dict())\n",
    "        for line in df.values:\n",
    "            dataset_, model_, method_, ns_, metric_, val_, std_, len_ = line\n",
    "            if 'ts' not in method_: continue\n",
    "            if 'aug' not in method_:\n",
    "                method_ = method_.replace('-augment', '').replace(' (ts)', '')\n",
    "                if dataset_ == dataset and model_==model and method_ == method and metric_ in precition:\n",
    "                    if metric_ == 'acc':\n",
    "                        metrics[metric_][ns_] = '?'+ (precition[metric_] % (100*(1-val_))) + '?'\n",
    "                        std = precition[metric_] % (std_*100)\n",
    "                    if metric_ == 'll':\n",
    "                        metrics[metric_][ns_] = '?' + (precition[metric_] % -val_) + '?'\n",
    "                        std = precition[metric_] % std_\n",
    "\n",
    "            else:\n",
    "                method_ = method_.replace('-augment', '').replace(' (ts)', '')\n",
    "                if dataset_ == dataset and model_==model and method_ == method and metric_ in precition:\n",
    "                    if metric_ == 'acc':\n",
    "                        metrics_[metric_][ns_] = '?'+ (precition[metric_] % (100*(1-val_)))\n",
    "                        metrics_std[metric_][ns_] = precition[metric_] % (std_*100)\n",
    "                    if metric_ == 'll':\n",
    "                        metrics_[metric_][ns_] = '?' + (precition[metric_] % -val_)\n",
    "                        metrics_std[metric_][ns_] = precition[metric_] % std_\n",
    "\n",
    "        def get_arrow(x):\n",
    "            prev = metrics[x[0]][x[1]].replace('?', '')\n",
    "            cur = metrics_[x[0]][x[1]].replace('?', '')\n",
    "            std =  metrics_std[x[0]][x[1]]\n",
    "            if prev == cur:\n",
    "                s = '≈'\n",
    "            elif np.abs(float(cur)-float(prev)) <= float(std):\n",
    "                s = '≈'\n",
    "            elif float(prev) > float(cur):\n",
    "                s = '↓'\n",
    "            else:\n",
    "                s = '↑'\n",
    "            return s\n",
    "\n",
    "        f = lambda x: metrics[x[0]][x[1]]+vs+metrics_[x[0]][x[1]] + get_arrow(x)\n",
    "        if metrics: \n",
    "            if dataset != 'ImageNet':\n",
    "                rows[row_counter] = [model, names_long[method]]\n",
    "                rows[row_counter] += list(map(f, [('acc', 5), ('acc', 10), ('acc', 100), ('ll', 5), ('ll', 10), ('ll', 100)]))\n",
    "                columns = ['Model', 'Method', 'acc(5)', 'acc(10)', 'acc(100)', 'll(5)', 'll(10)', 'll(100)']\n",
    "            else:\n",
    "                rows[row_counter] = [model, names_long[method]]\n",
    "                rows[row_counter] += list(map(f, [('acc', 5), ('acc', 10), ('acc', 50), ('ll', 5), ('ll', 10), ('ll', 50)]))\n",
    "                columns = ['Model', 'Method', 'acc(5)', 'acc(10)', 'acc(50)', 'll(5)', 'll(10)', 'll(50)']\n",
    "            row_counter+=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Model</th>\n",
       "      <th>Method</th>\n",
       "      <th>acc(5)</th>\n",
       "      <th>acc(10)</th>\n",
       "      <th>acc(50)</th>\n",
       "      <th>ll(5)</th>\n",
       "      <th>ll(10)</th>\n",
       "      <th>ll(50)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ResNet50</td>\n",
       "      <td>Fast Geometric Ens.</td>\n",
       "      <td>?23.61?$%.3f$ vs $%.3f$?22.21↓</td>\n",
       "      <td>?23.56?$%.3f$ vs $%.3f$?21.37↓</td>\n",
       "      <td>?23.28?$%.3f$ vs $%.3f$?20.67↓</td>\n",
       "      <td>?0.921?$%.3f$ vs $%.3f$?0.894↓</td>\n",
       "      <td>?0.916?$%.3f$ vs $%.3f$?0.842↓</td>\n",
       "      <td>?0.904?$%.3f$ vs $%.3f$?0.793↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ResNet50</td>\n",
       "      <td>Deep Ensembles</td>\n",
       "      <td>?21.19?$%.3f$ vs $%.3f$?21.20≈</td>\n",
       "      <td>?20.90?$%.3f$ vs $%.3f$?20.16↓</td>\n",
       "      <td>?20.63?$%.3f$ vs $%.3f$?19.39↓</td>\n",
       "      <td>?0.823?$%.3f$ vs $%.3f$?0.855↑</td>\n",
       "      <td>?0.805?$%.3f$ vs $%.3f$?0.793↓</td>\n",
       "      <td>?0.788?$%.3f$ vs $%.3f$?0.739↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ResNet50</td>\n",
       "      <td>Single model</td>\n",
       "      <td>?23.86?$%.3f$ vs $%.3f$?22.39↓</td>\n",
       "      <td>?23.86?$%.3f$ vs $%.3f$?21.60↓</td>\n",
       "      <td>?23.86?$%.3f$ vs $%.3f$?21.06↓</td>\n",
       "      <td>?0.938?$%.3f$ vs $%.3f$?0.900↓</td>\n",
       "      <td>?0.938?$%.3f$ vs $%.3f$?0.851↓</td>\n",
       "      <td>?0.938?$%.3f$ vs $%.3f$?0.805↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ResNet50</td>\n",
       "      <td>Variational Inf. (FFG)</td>\n",
       "      <td>?23.82?$%.3f$ vs $%.3f$?22.58↓</td>\n",
       "      <td>?23.77?$%.3f$ vs $%.3f$?21.74↓</td>\n",
       "      <td>?23.67?$%.3f$ vs $%.3f$?21.10↓</td>\n",
       "      <td>?0.927?$%.3f$ vs $%.3f$?0.905↓</td>\n",
       "      <td>?0.923?$%.3f$ vs $%.3f$?0.851↓</td>\n",
       "      <td>?0.920?$%.3f$ vs $%.3f$?0.805↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ResNet50</td>\n",
       "      <td>KFAC-Laplace</td>\n",
       "      <td>?24.19?$%.3f$ vs $%.3f$?22.50↓</td>\n",
       "      <td>?23.93?$%.3f$ vs $%.3f$?21.67↓</td>\n",
       "      <td>?23.86?$%.3f$ vs $%.3f$?21.04↓</td>\n",
       "      <td>?0.948?$%.3f$ vs $%.3f$?0.906↓</td>\n",
       "      <td>?0.939?$%.3f$ vs $%.3f$?0.855↓</td>\n",
       "      <td>?0.934?$%.3f$ vs $%.3f$?0.809↓</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>ResNet50</td>\n",
       "      <td>Snapshot Ensembles</td>\n",
       "      <td>?22.21?$%.3f$ vs $%.3f$?21.99↓</td>\n",
       "      <td>?21.75?$%.3f$ vs $%.3f$?20.81↓</td>\n",
       "      <td>?21.48?$%.3f$ vs $%.3f$?19.86↓</td>\n",
       "      <td>?0.865?$%.3f$ vs $%.3f$?0.879↑</td>\n",
       "      <td>?0.843?$%.3f$ vs $%.3f$?0.815↓</td>\n",
       "      <td>?0.830?$%.3f$ vs $%.3f$?0.763↓</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Model                  Method                          acc(5)                         acc(10)                         acc(50)                           ll(5)                          ll(10)                          ll(50)\n",
       "0  ResNet50     Fast Geometric Ens.  ?23.61?$%.3f$ vs $%.3f$?22.21↓  ?23.56?$%.3f$ vs $%.3f$?21.37↓  ?23.28?$%.3f$ vs $%.3f$?20.67↓  ?0.921?$%.3f$ vs $%.3f$?0.894↓  ?0.916?$%.3f$ vs $%.3f$?0.842↓  ?0.904?$%.3f$ vs $%.3f$?0.793↓\n",
       "1  ResNet50          Deep Ensembles  ?21.19?$%.3f$ vs $%.3f$?21.20≈  ?20.90?$%.3f$ vs $%.3f$?20.16↓  ?20.63?$%.3f$ vs $%.3f$?19.39↓  ?0.823?$%.3f$ vs $%.3f$?0.855↑  ?0.805?$%.3f$ vs $%.3f$?0.793↓  ?0.788?$%.3f$ vs $%.3f$?0.739↓\n",
       "2  ResNet50            Single model  ?23.86?$%.3f$ vs $%.3f$?22.39↓  ?23.86?$%.3f$ vs $%.3f$?21.60↓  ?23.86?$%.3f$ vs $%.3f$?21.06↓  ?0.938?$%.3f$ vs $%.3f$?0.900↓  ?0.938?$%.3f$ vs $%.3f$?0.851↓  ?0.938?$%.3f$ vs $%.3f$?0.805↓\n",
       "3  ResNet50  Variational Inf. (FFG)  ?23.82?$%.3f$ vs $%.3f$?22.58↓  ?23.77?$%.3f$ vs $%.3f$?21.74↓  ?23.67?$%.3f$ vs $%.3f$?21.10↓  ?0.927?$%.3f$ vs $%.3f$?0.905↓  ?0.923?$%.3f$ vs $%.3f$?0.851↓  ?0.920?$%.3f$ vs $%.3f$?0.805↓\n",
       "4  ResNet50            KFAC-Laplace  ?24.19?$%.3f$ vs $%.3f$?22.50↓  ?23.93?$%.3f$ vs $%.3f$?21.67↓  ?23.86?$%.3f$ vs $%.3f$?21.04↓  ?0.948?$%.3f$ vs $%.3f$?0.906↓  ?0.939?$%.3f$ vs $%.3f$?0.855↓  ?0.934?$%.3f$ vs $%.3f$?0.809↓\n",
       "5  ResNet50      Snapshot Ensembles  ?22.21?$%.3f$ vs $%.3f$?21.99↓  ?21.75?$%.3f$ vs $%.3f$?20.81↓  ?21.48?$%.3f$ vs $%.3f$?19.86↓  ?0.865?$%.3f$ vs $%.3f$?0.879↑  ?0.843?$%.3f$ vs $%.3f$?0.815↓  ?0.830?$%.3f$ vs $%.3f$?0.763↓"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df_ = pd.DataFrame.from_dict(rows, columns=columns, orient='index')\n",
    "display(df_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\\begin{tabular}{llllllll}\n",
      "\\toprule\n",
      "    Model &                  Method &                          acc(5) &                         acc(10) &                         acc(50) &                           ll(5) &                          ll(10) &                          ll(50) \\\\\n",
      "\\midrule\n",
      " ResNet50 &     Fast Geometric Ens. &  $23.61$\\$\\%.3f\\$ vs \\$\\%.3f\\$$22.21_{\\color{darkpastelgreen}{\\downarrow}}$ &  $23.56$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.37_{\\color{darkpastelgreen}{\\downarrow}}$ &  $23.28$\\$\\%.3f\\$ vs \\$\\%.3f\\$$20.67_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.921$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.894_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.916$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.842_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.904$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.793_{\\color{darkpastelgreen}{\\downarrow}}$ \\\\\n",
      " ResNet50 &          Deep Ensembles &  $21.19$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.20_{\\color{darkgray}{\\approx}}$ &  $20.90$\\$\\%.3f\\$ vs \\$\\%.3f\\$$20.16_{\\color{darkpastelgreen}{\\downarrow}}$ &  $20.63$\\$\\%.3f\\$ vs \\$\\%.3f\\$$19.39_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.823$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.855_{\\color{darkpink}{\\uparrow}}$ &  $0.805$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.793_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.788$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.739_{\\color{darkpastelgreen}{\\downarrow}}$ \\\\\n",
      " ResNet50 &            Single model &  $23.86$\\$\\%.3f\\$ vs \\$\\%.3f\\$$22.39_{\\color{darkpastelgreen}{\\downarrow}}$ &  $23.86$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.60_{\\color{darkpastelgreen}{\\downarrow}}$ &  $23.86$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.06_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.938$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.900_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.938$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.851_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.938$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.805_{\\color{darkpastelgreen}{\\downarrow}}$ \\\\\n",
      " ResNet50 &  Variational Inf. (FFG) &  $23.82$\\$\\%.3f\\$ vs \\$\\%.3f\\$$22.58_{\\color{darkpastelgreen}{\\downarrow}}$ &  $23.77$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.74_{\\color{darkpastelgreen}{\\downarrow}}$ &  $23.67$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.10_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.927$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.905_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.923$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.851_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.920$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.805_{\\color{darkpastelgreen}{\\downarrow}}$ \\\\\n",
      " ResNet50 &            KFAC-Laplace &  $24.19$\\$\\%.3f\\$ vs \\$\\%.3f\\$$22.50_{\\color{darkpastelgreen}{\\downarrow}}$ &  $23.93$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.67_{\\color{darkpastelgreen}{\\downarrow}}$ &  $23.86$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.04_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.948$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.906_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.939$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.855_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.934$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.809_{\\color{darkpastelgreen}{\\downarrow}}$ \\\\\n",
      " ResNet50 &      Snapshot Ensembles &  $22.21$\\$\\%.3f\\$ vs \\$\\%.3f\\$$21.99_{\\color{darkpastelgreen}{\\downarrow}}$ &  $21.75$\\$\\%.3f\\$ vs \\$\\%.3f\\$$20.81_{\\color{darkpastelgreen}{\\downarrow}}$ &  $21.48$\\$\\%.3f\\$ vs \\$\\%.3f\\$$19.86_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.865$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.879_{\\color{darkpink}{\\uparrow}}$ &  $0.843$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.815_{\\color{darkpastelgreen}{\\downarrow}}$ &  $0.830$\\$\\%.3f\\$ vs \\$\\%.3f\\$$0.763_{\\color{darkpastelgreen}{\\downarrow}}$ \\\\\n",
      "\\bottomrule\n",
      "\\end{tabular}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(df_.to_latex(index=False).replace(\n",
    "    '±', '{\\\\tiny $\\pm ').replace(\n",
    "    '!', '$}').replace(\n",
    "    '?', '$').replace('NAacc', '\\\\text{NA}\\hspace{5pt}').replace('NAll', '\\\\text{NA}\\hspace{8pt}').replace(\n",
    "    '↑', '_{\\color{darkpink}{\\\\uparrow}}$').replace(\n",
    "    '↓', '_{\\color{darkpastelgreen}{\\\\downarrow}}$').replace(\n",
    "    '≈', '_{\\color{darkgray}{\\\\approx}}$'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset = 'ImageNet'\n",
    "models = ['VGG16', 'ResNet110', 'ResNet164', 'WideResNet', 'ResNet50']\n",
    "methods = ['dropout', 'swag', 'csgld', 'fge', 'deepens', 'onenet', 'vi', 'kfacl', 'sse']\n",
    "\n",
    "rows, row_counter = defaultdict(lambda: dict()), 0\n",
    "for model in models:\n",
    "    for method in methods:\n",
    "        metrics = defaultdict(lambda: dict())\n",
    "        for line in df.values:\n",
    "            dataset_, model_, method_, ns_, metric_, val_, std_, len_ = line\n",
    "            if 'ts' not in method_: continue\n",
    "            if 'aug' in method_: continue\n",
    "            method_ = method_.replace('-augment', '').replace(' (ts)', '')\n",
    "            if dataset_ == dataset and model_==model and method_ == method and metric_ in precition:\n",
    "                if metric_ == 'acc':\n",
    "                    metrics[metric_][ns_] = '?'+ (precition[metric_] % (100*(1-val_))) + '?'\n",
    "                    std = precition[metric_] % (std_*100)\n",
    "                if metric_ == 'll':\n",
    "                    metrics[metric_][ns_] = '?' + (precition[metric_] % -val_) + '?'\n",
    "                    std = precition[metric_] % std_\n",
    "                                \n",
    "                if (method == 'deepens' and '10' in dataset and ns_==100) or (\n",
    "                        dataset=='ImageNet' and method_ == 'sse') or (\n",
    "                        dataset=='ImageNet' and method_ == 'deepens' and ns_==50):\n",
    "                        std = ('NAacc' if metric_ == 'acc' else 'NAll')\n",
    "                \n",
    "                if metric_ in metrics and ns_ in metrics[metric_]: \n",
    "                    metrics[metric_][ns_] += ('±' + std + '!')\n",
    "                \n",
    "        if metrics: \n",
    "            if dataset != 'ImageNet':\n",
    "                rows[row_counter] = [\n",
    "                    model, names_long[method], \n",
    "                    metrics['acc'][1], metrics['acc'][5], metrics['acc'][10], metrics['acc'][100],\n",
    "                    metrics['ll'][1],  metrics['ll'][5], metrics['ll'][10],  metrics['ll'][100]]\n",
    "                columns = ['Model', 'Method', 'acc(1)', 'acc(5)', 'acc(10)', 'acc(100)', 'll(1)', 'll(5)', 'll(10)', 'll(100)']\n",
    "            else:\n",
    "                rows[row_counter] = [\n",
    "                    model, names_long[method], \n",
    "                    metrics['acc'][1], metrics['acc'][5], metrics['acc'][10], metrics['acc'][50],\n",
    "                    metrics['ll'][1],  metrics['ll'][5], metrics['ll'][10],  metrics['ll'][50]]\n",
    "                columns = ['Model', 'Method', 'acc(1)', 'acc(5)', 'acc(10)', 'acc(50)', 'll(1)', 'll(5)', 'll(10)', 'll(50)']\n",
    "            row_counter+=1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\\begin{tabular}{llllllllll}\n",
      "\\toprule\n",
      "    Model &                  Method &          acc(1) &          acc(5) &         acc(10) &         acc(50) &           ll(1) &           ll(5) &          ll(10) &          ll(50) \\\\\n",
      "\\midrule\n",
      " ResNet50 &     Fast Geometric Ens. &   $23.71${\\tiny $\\pm 0.00$} &   $23.61${\\tiny $\\pm 0.00$} &   $23.56${\\tiny $\\pm 0.00$} &   $23.28${\\tiny $\\pm 0.00$} &  $0.929${\\tiny $\\pm 0.000$} &  $0.921${\\tiny $\\pm 0.000$} &  $0.916${\\tiny $\\pm 0.000$} &  $0.904${\\tiny $\\pm 0.000$} \\\\\n",
      " ResNet50 &          Deep Ensembles &   $23.79${\\tiny $\\pm 0.14$} &   $21.19${\\tiny $\\pm 0.14$} &   $20.90${\\tiny $\\pm 0.08$} &  $20.63${\\tiny $\\pm \\text{NA}\\hspace{5pt}$} &  $0.935${\\tiny $\\pm 0.007$} &  $0.823${\\tiny $\\pm 0.002$} &  $0.805${\\tiny $\\pm 0.000$} &   $0.788${\\tiny $\\pm \\text{NA}\\hspace{8pt}$} \\\\\n",
      " ResNet50 &            Single model &   $23.86${\\tiny $\\pm 0.20$} &   $23.86${\\tiny $\\pm 0.20$} &   $23.86${\\tiny $\\pm 0.20$} &   $23.86${\\tiny $\\pm 0.20$} &  $0.938${\\tiny $\\pm 0.006$} &  $0.938${\\tiny $\\pm 0.006$} &  $0.938${\\tiny $\\pm 0.006$} &  $0.938${\\tiny $\\pm 0.006$} \\\\\n",
      " ResNet50 &  Variational Inf. (FFG) &   $24.50${\\tiny $\\pm 0.06$} &   $23.82${\\tiny $\\pm 0.03$} &   $23.77${\\tiny $\\pm 0.04$} &   $23.67${\\tiny $\\pm 0.00$} &  $0.957${\\tiny $\\pm 0.001$} &  $0.927${\\tiny $\\pm 0.000$} &  $0.923${\\tiny $\\pm 0.001$} &  $0.920${\\tiny $\\pm 0.000$} \\\\\n",
      " ResNet50 &            KFAC-Laplace &   $25.01${\\tiny $\\pm 0.49$} &   $24.19${\\tiny $\\pm 0.29$} &   $23.93${\\tiny $\\pm 0.20$} &   $23.86${\\tiny $\\pm 0.16$} &  $0.988${\\tiny $\\pm 0.022$} &  $0.948${\\tiny $\\pm 0.013$} &  $0.939${\\tiny $\\pm 0.011$} &  $0.934${\\tiny $\\pm 0.008$} \\\\\n",
      " ResNet50 &      Snapshot Ensembles &  $24.92${\\tiny $\\pm \\text{NA}\\hspace{5pt}$} &  $22.21${\\tiny $\\pm \\text{NA}\\hspace{5pt}$} &  $21.75${\\tiny $\\pm \\text{NA}\\hspace{5pt}$} &  $21.48${\\tiny $\\pm \\text{NA}\\hspace{5pt}$} &   $0.983${\\tiny $\\pm \\text{NA}\\hspace{8pt}$} &   $0.865${\\tiny $\\pm \\text{NA}\\hspace{8pt}$} &   $0.843${\\tiny $\\pm \\text{NA}\\hspace{8pt}$} &   $0.830${\\tiny $\\pm \\text{NA}\\hspace{8pt}$} \\\\\n",
      "\\bottomrule\n",
      "\\end{tabular}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "df_ = pd.DataFrame.from_dict(rows, columns=columns, orient='index')\n",
    "print(df_.to_latex(index=False).replace(\n",
    "    '±', '{\\\\tiny $\\pm ').replace(\n",
    "    '!', '$}').replace(\n",
    "    '?', '$').replace('NAacc', '\\\\text{NA}\\hspace{5pt}').replace('NAll', '\\\\text{NA}\\hspace{8pt}'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Bar plots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!unzip df_dee_no_augment.csv.zip > unzip_out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/ars/miniconda3/lib/python3.7/site-packages/ipykernel_launcher.py:12: UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access\n",
      "  if sys.path[0] == '':\n"
     ]
    }
   ],
   "source": [
    "df = pd.read_csv('./df_dee_no_augment.csv')\n",
    "df.model = df.model.apply(lambda x: x.replace('do', '').replace('Bayes', ''))\n",
    "df.metric = df.metric.apply(lambda x: x.replace('_', '-'))\n",
    "df.method = df.method.apply(lambda x: x.lower().replace('_', '-').replace('kfaclaplace', 'kfacl'))\n",
    "\n",
    "df.model = df.model.apply(\n",
    "    lambda x: x.replace('BN', '').replace('Pre', '').replace('28x10', ''))\n",
    "df = df[df.method.apply(lambda x: 'ts' in x)]\n",
    "df = df[df.method.apply(lambda x: 'aug' not in x)]\n",
    "df = df[df.method != 'stochbn']\n",
    "df = df[df.metric == 'll']\n",
    "df.value = df.dee\n",
    "df.metric = len(df.dee)*['dee']\n",
    "\n",
    "df.method = df.method.apply(lambda x: x.replace('-augment', '').replace(' (ts)', ''))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>dataset</th>\n",
       "      <th>model</th>\n",
       "      <th>method</th>\n",
       "      <th>n_samples</th>\n",
       "      <th>metric</th>\n",
       "      <th>dee</th>\n",
       "      <th>lower</th>\n",
       "      <th>upper</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>700</th>\n",
       "      <td>700</td>\n",
       "      <td>CIFAR10</td>\n",
       "      <td>VGG16</td>\n",
       "      <td>dropout</td>\n",
       "      <td>1</td>\n",
       "      <td>dee</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>701</th>\n",
       "      <td>701</td>\n",
       "      <td>CIFAR10</td>\n",
       "      <td>VGG16</td>\n",
       "      <td>dropout</td>\n",
       "      <td>2</td>\n",
       "      <td>dee</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>702</th>\n",
       "      <td>702</td>\n",
       "      <td>CIFAR10</td>\n",
       "      <td>VGG16</td>\n",
       "      <td>dropout</td>\n",
       "      <td>3</td>\n",
       "      <td>dee</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.021788</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>703</th>\n",
       "      <td>703</td>\n",
       "      <td>CIFAR10</td>\n",
       "      <td>VGG16</td>\n",
       "      <td>dropout</td>\n",
       "      <td>4</td>\n",
       "      <td>dee</td>\n",
       "      <td>1.006517</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.044008</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>704</th>\n",
       "      <td>704</td>\n",
       "      <td>CIFAR10</td>\n",
       "      <td>VGG16</td>\n",
       "      <td>dropout</td>\n",
       "      <td>5</td>\n",
       "      <td>dee</td>\n",
       "      <td>1.023056</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.061072</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     Unnamed: 0  dataset  model   method  n_samples metric       dee  lower     upper\n",
       "700         700  CIFAR10  VGG16  dropout          1    dee  1.000000    1.0  1.000000\n",
       "701         701  CIFAR10  VGG16  dropout          2    dee  1.000000    1.0  1.000000\n",
       "702         702  CIFAR10  VGG16  dropout          3    dee  1.000000    1.0  1.021788\n",
       "703         703  CIFAR10  VGG16  dropout          4    dee  1.006517    1.0  1.044008\n",
       "704         704  CIFAR10  VGG16  dropout          5    dee  1.023056    1.0  1.061072"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset = 'ImageNet'\n",
    "models = ['VGG16', 'ResNet110', 'ResNet164', 'WideResNet', 'ResNet50']\n",
    "methods = ['deepens', 'sse', 'csgld', 'swag', 'fge', 'dropout', 'vi', 'kfacl', 'onenet']\n",
    "\n",
    "rows, row_counter = defaultdict(lambda: dict()), 0\n",
    "for model in models:\n",
    "    for method in methods:\n",
    "        metrics = defaultdict(lambda: dict())\n",
    "        metrics_ = defaultdict(lambda: dict())\n",
    "        metrics_std = defaultdict(lambda: dict())\n",
    "        for line in df.values:\n",
    "            _, dataset_, model_, method_, ns_, metric_, val_, std_, len_ = line\n",
    "            method_ = method_.replace('-augment', '').replace(' (ts)', '')\n",
    "            if dataset_ == dataset and model_==model and method_ == method:\n",
    "                metrics[metric_][ns_] = '?' + (precition[metric_] % val_) + '?'\n",
    "                std = precition[metric_] % std_\n",
    "\n",
    "        f = lambda x: metrics[x[0]][x[1]]\n",
    "        if metrics: \n",
    "            if dataset != 'ImageNet':\n",
    "                rows[row_counter] = [model, names_long[method]]\n",
    "                rows[row_counter] += list(map(f, [('dee', 1), ('dee', 5), ('dee', 10), ('dee', 50), ('dee', 100)]))\n",
    "                columns = ['Model', 'Method', 'dee(1)', 'dee(5)', 'dee(10)', 'dee(50)', 'dee(100)']\n",
    "            else:\n",
    "                rows[row_counter] = [model, names_long[method]]\n",
    "                rows[row_counter] += list(map(f, [('dee', 1), ('dee', 5), ('dee', 10), ('dee', 25), ('dee', 50)]))\n",
    "                columns = ['Model', 'Method', 'dee(1)', 'dee(5)', 'dee(10)', 'dee(25)', 'dee(50)']\n",
    "            row_counter+=1\n",
    "df_ = pd.DataFrame.from_dict(rows, columns=columns, orient='index')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\\begin{tabular}{lllllll}\n",
      "\\toprule\n",
      "    Model &                  Method & dee(1) & dee(5) & dee(10) & dee(25) & dee(50) \\\\\n",
      "\\midrule\n",
      " ResNet50 &          Deep Ensembles &  $1.0$ &  $5.0$ &  $10.0$ &  $25.0$ &  $50.0$ \\\\\n",
      " ResNet50 &      Snapshot Ensembles &  $1.0$ &  $2.2$ &   $3.2$ &   $4.0$ &   $4.2$ \\\\\n",
      " ResNet50 &     Fast Geometric Ens. &  $1.1$ &  $1.2$ &   $1.3$ &   $1.4$ &   $1.5$ \\\\\n",
      " ResNet50 &  Variational Inf. (FFG) &  $1.0$ &  $1.1$ &   $1.2$ &   $1.2$ &   $1.2$ \\\\\n",
      " ResNet50 &            KFAC-Laplace &  $1.0$ &  $1.0$ &   $1.0$ &   $1.0$ &   $1.0$ \\\\\n",
      " ResNet50 &            Single model &  $1.0$ &  $1.0$ &   $1.0$ &   $1.0$ &   $1.0$ \\\\\n",
      "\\bottomrule\n",
      "\\end{tabular}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "df_ = pd.DataFrame.from_dict(rows, columns=columns, orient='index')\n",
    "print(df_.to_latex(index=False).replace('?', '$'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQcAAAC/CAYAAADzRRkLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAHsAAAB7AB1IKDYgAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJza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4GlPVH4BjgZcStMg/4c66VwAzgGdwlwzfcuh+PE5E7gfaquonHLofK8rEJd9jgI/jHP+TuH1bRBz3p9WQNCYKEZlXoX3UQBCR83CXD22A2ar6ZbyWZcnBGOOrPlxWGGOSwJKDOSxWgavxsORgynmVzv5c4fOHIjI4YrS7ve/m1XCeNRrPBE99qARlEquViGQAnXFPh44WkQdwT4lux1XgGgQcLyJzcM/dLwSmAq1xlYCuwz1aKwWOT/wqmFiwkoOJtAQYCowAFlO5YlBHXMWfpUC+qv4HsNEbnq2q1+Nq7fUG8lR1EvBN4lfBxIIlBxPpv4HBQCtcp8h9IioGhe3y/pbgageGH3ulev8PVxorjW+4Jl4sOZhIJbiDO1xH/9aIikGFIjIiYppdwA4R+QPQ1pu2k1eBqENiwjaxZvUcjDG+rORgjPFlycEY48uSgzHGlyUHY4yv/wW/j/gBms7ztQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 300x200 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQ0AAAC/CAYAAADkZ4nCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAHsAAAB7AB1IKDYgAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAe90lEQVR4nO3deXxU9dX48U8SICESQASFiKhFOUgRVB6rtghYra3gUxda0LYqCm5U+SmCBIsLuEDEuvGoVVxwqywVl8elLr9WquCKoihwrFAhIoiIhgSSQJJ5/vjeCclk7mQmk1mSnPfrxYvMXc/cO3Pme+/93nMzAoEAxhgTrcxUB2CMaV4saRhjYmJJwxgTE0saxpiYtEl1AC2ViIwBCoDNuO28A/i1qlZEMe88QFV1Zq3XN6jql2GmHa2qC0RkAjAG2A68qKqzReRmYBjwiapeGjLfG6o6rJFvL1Lsw4B7gIGqWum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MWqq+h1wMPBMklb5CO5X+nxgBvAo7tDja+rvxx+JyO3APqr6MfX3Y225uKR8EPBhguN/ELdvy0ng/rRLrsbESETmqeqYVMdRm4ichjsM6QLMVtUvErUuSxrGmJg058MTY0wKWNIwTcY6p7UOljRMVLwOdY/Xev2+iAwLmexmb9y8KJcZ1XQmvTTnzl0m+TqJSA7QE3fF6kARuQN35eo6XOe0ocAh3o2KPYCzgGlAZ1wHpwm4y4BV7LkD2jQj1tIwsXgRGA6cCSymbqenHrhOTUtwBZguB9Z4w7uq6hW4nooDcOUTJgEbk/8WTLwsaZhY/H9gGNAJVy9lYEinp6Dt3v+VuB6RwUt0md7fwQ5xVYkN1ySCJQ0Ti0rclz54H8OfQjo9lYrImSHzbAe2isifgX28efO9zlHdkxO2aUrWT8MYExNraRhjYmJJwxgTE0saxpiYWNIwxsTk/wBFwrMQ4SlywQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 300x200 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = dfbase_ung\n",
    "\n",
    "q    = 'dataset == \"%s\" and model == \"%s\" and metric == \"%s\" and n_samples == 50'\n",
    "df  = df.query(q % ('ImageNet', 'ResNet50', 'acc'))\n",
    "df = df[df.method.apply(lambda x: 'ts' in x)]\n",
    "df['Test-time data augmentation'] = df.method.apply(lambda x: 'Enabled' if 'augment' in x else 'Disabled')\n",
    "df.method = df.method.apply(lambda x: x.replace('-augment', '').replace(' (ts)', ''))\n",
    "df['Top-1 Error (%)'] = 100*(1-df['value'].values)\n",
    "df['Method'] = df['method']\n",
    "\n",
    "mpl.rcParams['figure.dpi'] = 50\n",
    "plt.title('ResNet50 ImageNet (50 samples)')\n",
    "ax = sns.barplot(x=\"Method\", y=\"Top-1 Error (%)\", hue='Test-time data augmentation', data=df)\n",
    "\n",
    "plt.ylim(15, 27)\n",
    "plt.savefig('./pdf/barplot-err.pdf',bbox_inches='tight', pad_inches=0.05)\n",
    "\n",
    "plt.figure()\n",
    "df = dfbase_ung\n",
    "\n",
    "q    = 'dataset == \"%s\" and model == \"%s\" and metric == \"%s\" and n_samples == 50'\n",
    "df  = df.query(q % ('ImageNet', 'ResNet50', 'll'))\n",
    "df = df[df.method.apply(lambda x: 'ts' in x)]\n",
    "df['Test-time data augmentation'] = df.method.apply(lambda x: 'Enabled' if 'augment' in x else 'Disabled')\n",
    "df.method = df.method.apply(lambda x: x.replace('-augment', '').replace(' (ts)', ''))\n",
    "df['Neg. Calibrated Log-Likelihood'] = -df['value'].values\n",
    "df['Method'] = df['method']\n",
    "df = df[df.method != 'stochbn']\n",
    "\n",
    "mpl.rcParams['figure.dpi'] = 50\n",
    "plt.title('ResNet50 ImageNet (50 samples)')\n",
    "ax = sns.barplot(x=\"Method\", y=\"Neg. Calibrated Log-Likelihood\", hue='Test-time data augmentation', data=df)\n",
    "\n",
    "plt.ylim(0.65, 1.01)\n",
    "plt.savefig('./pdf/barplot-cll.pdf',bbox_inches='tight', pad_inches=0.05)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQ8AAADGCAYAAADMvwX2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAHsAAAB7AB1IKDYgAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAASw0lEQVR4nO3de3hV1ZnH8W8ghAAREKbiDVGsecWpl4KXovVGa9VWar2AjuKF1npldKZTO9NqnxhbW1scb6UtOlRph3ZmnnopTC9WbZ1aHHU6eKG19lVRGazWWOTiAQIJnPlj7dgQEwkra5+Tk/w+z5OHkJysd51kn99ee+191q4qFouIiGyvAeXugIhUJoWHiERReIhIFIWHiETpcXiY2bFmNtfMTjCzeWb2L2Y20MzON7Nvm9kNKTq6Hf05XrVUS7Xy16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1/rAFRceZjaOMKfxFcIVo43AJwkLD92S/fv7VBtmFlRnAH9FmBMo9JVDilLKLpxrzT7vE8HRpv1zy6Ht9xNG2PMJI9+fAb8ADgfuL+fvsSLCI7t244OEi7GuAn5JmHQ7CVgMvNfdLzKzgdmEY5596VMbfqnp97d9zOwwYKy732VmxxJGIGennIyN1atP1bbb0HYjDHmHEs5jP004zlwM7Orus7MfyX00oA2/Z/T7225PALPMrAX4OPDt3hAcUDkjj+uAUcAhhLdXn0e4avTStok37dGkr8ou5z8YKLj7knL3p02vDw8z2xE4LzvjcQghNH5GeI9HWRZ+FZEKCA94+4zHj4EJwPuAL7r72vL2SqR/q5QrTL9ImPcYTLjGQsEhUmYVMfLoSPMbIuVXkeEhIuVXKYctItLLKDykR8xs13L3QcpD4SE9dR2Amc3vzoO7+zjp/Xr1FaZSXmZ2DWGJwH0IC+nWA48T3nq+I2Fx4YkW7ocz0sxuJawvcS7wN4Q3Ew4FLiEszjSMsPKa9AEaeci2zCesv/E4YUHpWwkrnK0nrAb2pLv/iLDy2RWEWw28j7D47izCBX3HAzu6+5WEFb2lD1B4yLYUCMGwkbB2xFuEUcRcwhodbafrCtnp81bCCldtK18NaPc5WRvSB+iwRbbXtYQlC4cSln1cZmaXdvK4R7PDmAGEFa/2N7MbCKMS6QN0nYeIRNFhi4hEUXiISBSFh4hEUXiISJT/B93/InIEt0dYAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 300x200 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "f, (ax1, ax2) = plt.subplots(2, 1, sharex=True)\n",
    "f.subplots_adjust(hspace=0.05) \n",
    "\n",
    "df = pd.read_csv('./df_dee_no_augment.csv')\n",
    "df = df[df.method.apply(lambda x: 'ts' in x)]\n",
    "df = df[df.method.apply(lambda x: 'augment' not in x)]\n",
    "df.method = df.method.apply(lambda x: x.replace('-augment', '').replace(' (ts)', '').replace('kfaclaplace', 'kfacl'))\n",
    "df = df[df.method != 'stochbn']\n",
    "# df = df[df.method != 'deepens']\n",
    "\n",
    "q    = 'dataset == \"%s\" and model == \"%s\" and metric == \"%s\" and n_samples == 100'\n",
    "df  = df.query(q % ('CIFAR100', 'PreResNet110', 'll'))\n",
    "sns.barplot(x=\"method\", y=\"dee\", data=df, palette=colors, \n",
    "                 order=['deepens', 'csgld', 'sse', 'fge', 'swag', 'vi', 'kfacl', 'onenet'], ax=ax1)\n",
    "sns.barplot(x=\"method\", y=\"dee\", data=df, palette=colors, \n",
    "                 order=['deepens', 'csgld', 'sse', 'fge', 'swag', 'vi', 'kfacl', 'onenet'], ax=ax2)\n",
    "\n",
    "\n",
    "# zoom-in / limit the view to different portions of the data\n",
    "ax1.set_ylim(85.1, 100)  # outliers only\n",
    "ax2.set_ylim(0, 14.9)  # most of the data\n",
    "\n",
    "ax1.set_xlabel('')\n",
    "\n",
    "# # hide the spines between ax and ax2\n",
    "\n",
    "ax1.xaxis.tick_top()\n",
    "ax1.tick_params(labeltop=False)  # don't put tick labels at the top\n",
    "ax2.xaxis.tick_bottom()\n",
    "\n",
    "d = .015  # how big to make the diagonal lines in axes coordinates\n",
    "# arguments to pass to plot, just so we don't keep repeating them\n",
    "kwargs = dict(transform=ax1.transAxes, color='gray', alpha=0.7, clip_on=False)\n",
    "ax1.plot((-d, +d), (-d, +d), **kwargs)        # top-left diagonal\n",
    "ax1.plot((1 - d, 1 + d), (-d, +d), **kwargs)  # top-right diagonal\n",
    "\n",
    "kwargs.update(transform=ax2.transAxes)  # switch to the bottom axes\n",
    "ax2.plot((-d, +d), (1 - d, 1 + d), **kwargs)  # bottom-left diagonal\n",
    "ax2.plot((1 - d, 1 + d), (1 - d, 1 + d), **kwargs)  # bottom-right diagonal\n",
    "\n",
    "plt.xticks(rotation=40)\n",
    "\n",
    "ax1.spines['bottom'].set_visible(False)\n",
    "ax2.spines['top'].set_visible(False)\n",
    "plt.savefig('./pdf/barplot-dee.pdf',bbox_inches='tight', pad_inches=0.05)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
